return path->elems->len;
}
+/**
+ * gtk_widget_path_to_string:
+ * @path: the path
+ *
+ * Dumps the widget path into a string representation. It tries to match
+ * the CSS style as closely as possible (Note that there might be paths
+ * that cannot be represented in CSS).
+ *
+ * The main use of this code is for debugging purposes, so that you can
+ * g_print() the path or dump it in a gdb session.
+ *
+ * Returns: A new string describing @path.
+ **/
+char *
+gtk_widget_path_to_string (const GtkWidgetPath *path)
+{
+ GString *string;
+ guint i, j;
+
+ g_return_val_if_fail (path != NULL, NULL);
+
+ string = g_string_new ("");
+
+ for (i = 0; i < path->elems->len; i++)
+ {
+ GtkPathElement *elem;
+
+ elem = &g_array_index (path->elems, GtkPathElement, i);
+
+ if (i > 0)
+ g_string_append_c (string, ' ');
+
+ g_string_append (string, g_type_name (elem->type));
+
+ if (elem->name)
+ {
+ g_string_append_c (string, '(');
+ g_string_append (string, g_quark_to_string (elem->name));
+ g_string_append_c (string, ')');
+ }
+
+ if (elem->classes)
+ {
+ for (j = 0; j < elem->classes->len; j++)
+ {
+ g_string_append_c (string, '.');
+ g_string_append (string, g_quark_to_string (g_array_index (elem->classes, GQuark, j)));
+ }
+ }
+
+ if (elem->regions)
+ {
+ GHashTableIter iter;
+ gpointer key, value;
+
+ g_hash_table_iter_init (&iter, elem->regions);
+ while (g_hash_table_iter_next (&iter, &key, &value))
+ {
+ GtkRegionFlags flags = GPOINTER_TO_UINT (value);
+ static const char *flag_names[] = {
+ "even",
+ "odd",
+ "first",
+ "last",
+ "sorted"
+ };
+
+ g_string_append_c (string, ' ');
+ g_string_append (string, g_quark_to_string (GPOINTER_TO_UINT (key)));
+ for (j = 0; j < G_N_ELEMENTS(flag_names); j++)
+ {
+ if (flags & (1 << j))
+ {
+ g_string_append_c (string, ':');
+ g_string_append (string, flag_names[j]);
+ }
+ }
+ }
+ }
+ }
+
+ return g_string_free (string, FALSE);
+}
+
/**
* gtk_widget_path_prepend_type:
* @path: a #GtkWidgetPath